package com.wz.activity;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.content.Context;
import android.content.Intent;

/**
 * 创建识别参数
 *
 */
public class RecognitionParam {
	
	/**
	 * 设置识别参数
	 * @param context
	 * @return
	 */
	public Intent bindParams(Context context) {
		
		 Intent intent = new Intent();
		 
		 /**语音参数 start**/
		 intent.putExtra(Constant.EXTRA_SOUND_START, R.raw.bdspeech_recognition_start);
         intent.putExtra(Constant.EXTRA_SOUND_END, R.raw.bdspeech_speech_end);
         intent.putExtra(Constant.EXTRA_SOUND_SUCCESS, R.raw.bdspeech_recognition_success);
         intent.putExtra(Constant.EXTRA_SOUND_ERROR, R.raw.bdspeech_recognition_error);
         intent.putExtra(Constant.EXTRA_SOUND_CANCEL, R.raw.bdspeech_recognition_cancel);
         /**语音参数 end**/
         
         //自定义语法文件
         intent.putExtra("grammar", "asset:///baidu_speech_grammar.bsg"); 
         // 设置grammar中需要覆盖的词条,如联系人名,值为Son格式
         //intent.putExtra("slot-data", your slots); 
         intent.putExtra("slot-data", buildTestSlotData()); 
		
         return intent;
         
	}
	
	
	 private String buildTestSlotData() {
	        JSONObject slotData = new JSONObject();
	        JSONArray name = new JSONArray().put("李涌泉").put("郭下纶").put("张三").put("李四");
	        JSONArray song = new JSONArray().put("七里香").put("发如雪");
	        JSONArray artist = new JSONArray().put("周杰伦").put("李世龙");
	        JSONArray app = new JSONArray().put("手机百度").put("百度地图");
	        JSONArray usercommand = new JSONArray().put("关灯").put("开门");
	        try {
	            slotData.put(Constant.EXTRA_OFFLINE_SLOT_NAME, name);
	            slotData.put(Constant.EXTRA_OFFLINE_SLOT_SONG, song);
	            slotData.put(Constant.EXTRA_OFFLINE_SLOT_ARTIST, artist);
	            slotData.put(Constant.EXTRA_OFFLINE_SLOT_APP, app);
	            slotData.put(Constant.EXTRA_OFFLINE_SLOT_USERCOMMAND, usercommand);
	        } catch (JSONException e) {

	        }
	        return slotData.toString();
	    }

}
